package com.example.userregister;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class ShopActivity extends AppCompatActivity implements View.OnClickListener{
    equipItem magic;
    private TextView name,life,attack,speed;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);

        magic = new equipItem("魔法药水", 45, 70, 33);
        findViewById(R.id.eq_layout).setOnClickListener(this);

        //获取装备页面的控件
        name = findViewById(R.id.name);
        life = findViewById(R.id.tv_life);
        attack = findViewById(R.id.tv_attack);
        speed = findViewById(R.id.tv_speed);

        //给装备属性设置值
        name.setText(magic.getName());
        life.setText("生命值"+magic.getLife());
        attack.setText("攻击力"+magic.getAttack());
        speed.setText("敏捷度"+magic.getSpeed());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.eq_layout:
                //创建意图对象
                Intent intent = new Intent();
                //将数据存到意图中
                intent.putExtra("equip",magic);
                //把数据返回
                setResult(1,intent);
                //把当前页面关闭
                finish();
                break;
        }

    }
}
